package com.bwie.home.backstage.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bwie.home.common.utils.PageUtils;
import com.bwie.home.common.utils.Query;

import com.bwie.home.backstage.dao.UserHousesRemarkDao;
import com.bwie.home.backstage.entity.UserHousesRemarkEntity;
import com.bwie.home.backstage.service.UserHousesRemarkService;


@Service("userHousesRemarkService")
public class UserHousesRemarkServiceImpl extends ServiceImpl<UserHousesRemarkDao, UserHousesRemarkEntity> implements UserHousesRemarkService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<UserHousesRemarkEntity> page = this.page(
                new Query<UserHousesRemarkEntity>().getPage(params),
                new QueryWrapper<>()
        );

        return new PageUtils(page);
    }
    @Override
    public PageUtils UserHousesRemarkList(Map<String, Object> params) {
        IPage<UserHousesRemarkEntity> page = null;
        Integer pageIndex = 1;
        Integer pageSize =2;
        UserHousesRemarkEntity pingjia = new UserHousesRemarkEntity();
        if(params!=null){
            //判断模糊查询如果不为空赋值于值,否知空值
            if(( params.get("name")!=null && params.get("name")!="")){
                pingjia.setHousesName((String)params.get("name"));
            }

            if(( params.get("remarkStatic")!=null && !"".equals(params.get("remarkStatic").toString()))){
                pingjia.setRemarkStatic(Integer.parseInt(params.get("remarkStatic").toString()));
            }

            //如果不为空赋值 pageIndex  pageSize
            if( params.get("pageIndex")!=null &&  (Integer)params.get("pageIndex")>0 &&  params.get("pageSize")!=null && (Integer) params.get("pageSize")>0){
                pageIndex = (Integer)params.get("pageIndex");
                pageSize = (Integer) params.get("pageSize");
            }
            //为空走默认
            Page<UserHousesRemarkEntity> UserHousesRemark =
                    new Page<>(pageIndex, pageSize);
            page = baseMapper.UserHousesRemark(UserHousesRemark,pingjia);
        }
        assert page != null;
        return new PageUtils(page);
    }

    @Override
    public UserHousesRemarkEntity getremarkId(Integer remarkId) {
        return baseMapper.getremarkId(remarkId);
    }

}